﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Twipler.Xtensions
{
    public static class HttpRequest
    {
        public static int? QueryStringInt(this System.Web.HttpRequest request, string name)
        {
            int i;
            if (int.TryParse(request.QueryString[name], out i))
                return i;

            return null;
        }

        public static string QueryStringString(this System.Web.HttpRequest request, string name, string defaultValue)
        {
            if (request.QueryString[name] == null)
                return defaultValue;

            return request.QueryString[name];
        }

        public static bool QueryStringBool(this System.Web.HttpRequest request, string name, bool defaultValue)
        {
            if (request.QueryString[name] == null)
                return defaultValue;

            return (request.QueryString[name] == "t");
        }
    }
}
